<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>配资审核</title>

<link href="${ctx}/resources/media/css/chosen.css" rel="stylesheet"
	type="text/css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/media/css/bootstrap-wysihtml5.css" />

    <script type="text/javascript"
	src="${ctx}/resources/media/js/bootstrap-fileupload.js"></script>
<script type="text/javascript"
	src="${ctx}/resources/media/js/chosen.jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/media/css/datetimepicker.css" />
    
</head>
<body>
	<div class="row-fluid profile">
		<div class="span12">
			<!--BEGIN TABS-->
			<div class="tabbable tabbable-custom tabbable-full-width">
				<ul class="nav nav-tabs">
					<li><a href="${ctx}/loan/audit">配资列表</a></li>
					<li class="active"><a href="${ctx}/loan/view/${loan.id}">配资审核</a></li>
				</ul>
				<div class="tab-content">
					<!--end tab-pane-->
					<div class="tab-pane profile-classic row-fluid active" id="tab_1_2">
						<div class="span12">
							<!-- BEGIN SAMPLE FORM PORTLET-->
							<div class="portlet box blue">
								<div class="portlet-title">
									<div class="caption">
										<i class="icon-reorder"></i> <span class="hidden-480">配资审核</span>
									</div>
								</div>
								<!-- END SAMPLE FORM PORTLET-->
								<div class="portlet-body form">
									<form class="form-horizontal" id="form" action="${ctx}/loan/audit.html" method="post" onsubmit="return valid()">
										<fieldset>
											<input id="id" type="hidden" name="id" value="${loan.id }">
											<input type="hidden"  name="version" value="${loan.version }">
                                            <h4 class="form-section">配资申请信息</h4>
                                            <div class="row-fluid">
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">配资人</label>
                                                        <div class="controls">
                                                            <input type="text" value="${loan.member.userName}" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">申请时间</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatDate value="${loan.applyDate}" pattern="yyyy-MM-dd HH:mm:ss" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row-fluid">
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">保证金</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatNumber value="${loan.depositAmount}" pattern="###,###.##元" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">配资金额</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatNumber value="${loan.loanAmount}" pattern="###,###.##元" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row-fluid">
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">杠杆</label>
                                                        <div class="controls">
                                                            <input type="text" value="${loan.leverageRatio}倍配资" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">使用期限</label>
                                                        <div class="controls">
                                                            <input type="text" value="${loan.term}个${loan.termUnit}" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row-fluid">
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">年利率</label>
                                                        <div class="controls">
                                                            <input type="text" value="${loan.rate}%" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">保证金缴纳时间</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatDate value="${loan.tradeDate}" pattern="yyyy-MM-dd HH:mm:ss" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row-fluid">
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">警告线</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatNumber value="${loan.warningBalance}" pattern="###,###.##元" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="span6">
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label">强制平仓线</label>
                                                        <div class="controls">
                                                            <input type="text" value="<fmt:formatNumber value="${loan.autoCloseBalance}" pattern="###,###.##元" />" class="m-wrap input-xlarge" disabled="disabled">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <h4 class="form-section">审核意见</h4>
                                            <div class="control-group">
                                                <label class="control-label">审批</label>
                                                <div class="controls">
                                                    <!-- Inline Radios -->
                                                    <label class="radio inline">
                                                        <input type="radio" value="0" name="status"> 通过
                                                    </label>
                                                    <label class="radio inline">
                                                        <input type="radio" value="3" name="status"  checked="checked"> 不通过
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <!-- Text input-->
                                                <label class="control-label">意见</label>
                                                <div class="controls">
                                                    <textarea name="remarks" id="remarks" class="m-wrap "
                                                              style="margin: 0px;" cols="150" rows="3"></textarea>
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>

                                            <div class="row-fluid hide finance" >
                                                <div class="span12">
                                                    <h4 class="form-section">融资信息配置</h4>
                                                    <div class="control-group">
                                                        <!-- Text input-->
                                                        <label class="control-label">标的标题</label>
                                                        <div class="controls">
                                                            <input type="text" value="" id="title" name="title" class="m-wrap input-xxlarge">
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">最小投资金额</label>
                                                                <div class="controls">
                                                                    <input type="text" value="" id="min_invest_amount" name="minInvestAmount" class="m-wrap input-large">
                                                                    <p class="help-block"></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">投资利率</label>
                                                                <div class="controls">
                                                                    <input type="text" value="${loan.rate}" readonly="readonly" id="min_invest_rate" name="minInvestRate" placeholder="百分比" class="m-wrap input-small">
                                                                    <p class="help-block"></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span12">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">最大投资金额</label>
                                                                <div class="controls">
                                                                    <input type="text" value="" id="max_invest_amount" name="maxInvestAmount" class="m-wrap input-large">
                                                                    <p class="help-block"></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="span6 hide">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">最大投资利率</label>
                                                                <div class="controls">
                                                                    <input type="text" value="${loan.rate}" id="max_invest_rate" name="maxInvestRate" placeholder="百分比" class="m-wrap input-small">
                                                                    <p class="help-block"></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">投资开始时间</label>
                                                                <div class="controls">
                                                                    <div class="input-append date form_meridian_datetime">
                                                                        <input size="16" type="text" id="start_time" name="startTime" value="" readonly class="m-wrap">
                                                                        <span class="add-on"><i class="icon-remove"></i></span>
                                                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <!-- Text input-->
                                                                <label class="control-label">投资结束时间</label>
                                                                <div class="controls">
                                                                    <div class="input-append date form_meridian_datetime">
                                                                        <input size="16" type="text" id="end_time" name="endTime" value="" readonly class="m-wrap">
                                                                        <span class="add-on"><i class="icon-remove"></i></span>
                                                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="control-group">

                                                        <!-- Text input-->
                                                        <label class="control-label" for="input01">标的介绍</label>
                                                        <div class="controls">
                                                            <textarea class="wysihtml5 m-wrap" style="width:620px" name="description" id="content" rows="6">${notice.content }</textarea>
                                                            <p class="help-block"></p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

										</fieldset>
										<div class="form-actions">
											<button type="submit" class="btn blue ibtsubmit">
												<i class="icon-ok"></i> 保存
											</button>
                                            <button type="button" onclick="history.go(-1)" class="btn">取消</button>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!--END TABS-->
			</div>
		</div>
	</div>

    <script type="text/javascript"
            src="${ctx}/resources/media/js/select2.min.js"></script>
    <link rel="stylesheet" type="text/css"
          href="${ctx}/resources/media/css/select2_metro.css" />
    <script type="text/javascript" src="${ctx}/resources/media/js/wysihtml5-0.3.0.js"></script>
    <script type="text/javascript" src="${ctx}/resources/media/js/bootstrap-wysihtml5.js"></script>
    <script type="text/javascript" src="${ctx}/resources/media/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript">


        $(function(){

            $("select").select2();

            if ($('.wysihtml5').size() > 0) {
                $('.wysihtml5').wysihtml5({
                });
            }

            $(".form_meridian_datetime").datetimepicker({
                format: "yyyy-m-d h:i",
                //showMeridian: true,
                language:"zh",
                autoclose: true,
                pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left"),
                todayBtn: true
            });

            $("input[type='radio']").click(function(){
                var value = $(this).val();
                if(value == 0){
                    $(".finance").show();
                }else{
                    $(".finance").hide();
                }
            })

            if($("input[type='radio'][value='0']").attr("checked")){
                $(".finance").show();
            }

            function valid(){

                var title = $("#title").val();
                var loanId = $("#id").val();
                var status = $("input[type='radio'][value='0']").attr("checked") ? 0 : 3;
                var remarks = $("#remarks").val();
                var minAmount = $("#min_invest_amount").val();
                var maxAmount = $("#max_invest_amount").val();
                var minRate = $("#min_invest_rate").val();
                var maxRate = $("#max_invest_rate").val();
                var startTime = $("#start_time").val();
                var endTime = $("#end_time").val();
                var content = $("#content").val();

                if(status == 3 && remarks == ""){
                    alert("请输入审核意见");
                    return;
                }

                if(status == 0){



                if(title == "" || title.length == 0){
                    alert("请输入标的标题");
                    return false;
                }

                if(minAmount == "" || parseFloat(minAmount) < 0){
                    alert("请输入最小投资金额，不限请输入0");
                    return false;
                }

                if(minRate == "" || parseFloat(minRate) < 0 || parseFloat(minRate) > 100){
                    alert("请输入最小投资利率，范围0~100");
                    return false;
                }

                if(maxAmount == "" || parseFloat(maxAmount) < 0){
                    alert("请输入最大投资金额，不限请输入0");
                    return false;
                }

                if(maxAmount != 0 && maxAmount < minAmount){
                    alert("最大投资金额不能小于最小投资金额");
                    return false;
                }

                if(maxRate == "" || parseFloat(maxRate) < 0 ){
                    alert("请输入最大投资利率");
                    return ;
                }

                if(parseFloat(maxRate) < parseFloat(minRate)){

                    alert("最大投资利率不能小于最小投资利率");
                    return false;
                }

                if(startTime > endTime){
                    alert("投资开始时间不能大于投资结束时间");
                    return;
                }
                }


                return true;
            }

        });

    </script>


</body>
</html>